package com.example.tests;



public class ContactData implements Comparable<ContactData>{
	
	private int id;
	private String firstName;
	private String lastName;
	private String address;
	private String homePhone;
	private String mobilePhone;
	private String workPhone;
	private String email;
	private String additionalEmail;
	private String bday;
	private int bmonth;
	private String byear;
	private String secondaryAddress;
	private String secondaryPhone;
	private String group;
	
	public ContactData(){		
	}

	@Override
	public String toString() {
		return "ContactData [id=" + id + ", firstName=" + firstName
				+ ", lastName=" + lastName + ", address=" + address
				+ ", homePhone=" + homePhone + ", mobilePhone=" + mobilePhone
				+ ", workPhone=" + workPhone + ", email=" + email
				+ ", additionalEmail=" + additionalEmail + ", bday=" + bday
				+ ", bmonth=" + bmonth + ", byear=" + byear
				+ ", secondaryAddress=" + secondaryAddress
				+ ", secondaryPhone=" + secondaryPhone + ", group=" + group
				+ "]";
	}

	@Override
	public int hashCode() {
		//final int prime = 31;
		int result = 1;
		//result = prime * result + ((email == null) ? 0 : email.hashCode());
		//result = prime * result
		//		+ ((firstName == null) ? 0 : firstName.hashCode());
		//result = prime * result
		//		+ ((homePhone == null) ? 0 : homePhone.hashCode());
		//result = prime * result
		//		+ ((lastName == null) ? 0 : lastName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ContactData other = (ContactData) obj;
		if (email == null) {
			if (other.email != null)
				return false;
		} else if (!email.equals(other.email))
			return false;
		if (firstName == null) {
			if (other.firstName != null)
				return false;
		} else if (!firstName.equals(other.firstName))
			return false;
		if (homePhone == null) {
			if (other.homePhone != null)
				return false;
		} else if (!homePhone.equals(other.homePhone))
			return false;
		if (lastName == null) {
			if (other.lastName != null)
				return false;
		} else if (!lastName.equals(other.lastName))
			return false;
		return true;
	}

	@Override
	public int compareTo(ContactData other) {
		int result=this.lastName.toLowerCase().compareTo(other.lastName.toLowerCase());
		if (result==0){
			result = this.firstName.toLowerCase().compareTo(other.firstName.toLowerCase());
			if (result==0){
				if (this.id>other.id)
					return 1;
				else 
					return -1;				
			}
			else
				return result;
		}
		else
			return result;
	}

	public ContactData withFirstName(String firstName) {
		this.firstName = firstName;
		return this;
	}

	public ContactData withLastName(String lastName) {
		this.lastName = lastName;
		return this;
	}

	public ContactData withAdress(String adress) {
		address = adress;
		return this;
	}

	public ContactData withHomePhone(String homePhone) {
		this.homePhone = homePhone;
		return this;
	}

	public ContactData withMobilePhone(String mobilePhone) {
		this.mobilePhone = mobilePhone;
		return this;
	}

	public ContactData withWorkPhone(String workPhone) {
		this.workPhone = workPhone;
		return this;
	}

	public ContactData withEmail(String email) {
		this.email = email;
		return this;
	}

	public ContactData withBday(String bday) {
		this.bday = bday;
		return this;
	}

	public ContactData withBmonth(int bmonth) {
		this.bmonth = bmonth;
		return this;
	}

	public ContactData withByear(String byear) {
		this.byear = byear;
		return this;
	}

	public ContactData withSecondaryAddress(String secondaryAddress) {
		this.secondaryAddress = secondaryAddress;
		return this;
	}

	public ContactData withSecondaryPhone(String secondaryPhone) {
		this.secondaryPhone = secondaryPhone;
		return this;
	}

	public ContactData withContactId(int id) {
		this.id = id;
		return this;
	}
	
	public ContactData withGroup(String group) {
		this.group = group;
		return this;		
	}

	public int getId() {
		return id;
	}

	public String getFirstName() {
		return firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public String getAddress() {
		return address;
	}

	public String getHomePhone() {
		return homePhone;
	}

	public String getMobilePhone() {
		return mobilePhone;
	}

	public String getWorkPhone() {
		return workPhone;
	}

	public String getEmail() {
		return email;
	}

	public String getAdditionalEmail() {
		return additionalEmail;
	}

	public String getBday() {
		return bday;
	}

	public int getBmonth() {
		return bmonth;
	}

	public String getByear() {
		return byear;
	}

	public String getSecondaryAddress() {
		return secondaryAddress;
	}

	public String getSecondaryPhone() {
		return secondaryPhone;
	}

	public String getGroup() {
		return group;
	}

	
	
}